// =============================================================================
//  Spangles Analyzer
//
//  Copyright(c) 2008
//  See LICENSE.txt for licensing information.
// =============================================================================

package com.google.spangles.domain;

/**
 * (Description)
 * (Any invariants [conditions that are always true] )
 * (Usage instructions, and/or examples)
 * (TODOs, ASSUMPTIONs, etc.)
 * (Known Bugs)
 * (Concurrency strategy - not thread safe or how it's thread safe)
 * 
 * @author Chris
 */
public class Color
{
   public static final Color BLACK = new Color("black");
   
   public static final Color WHITE = new Color("white");
   
   public static final Color GRAY = new Color("gray");
   
   private String name;
   
   private Color(String name)
   {
      this.name = name;
   }

   /**
    * (Description - what the method does and why)
    * (Visibility decision, if not obvious)
    * (Pre/Post Conditions)
    * (Usage examples)
    * (Algorithmic notes)
    * (Concurrency issues)
    * @return
    */
   public Color opponent()
   {
      if(equals(Color.WHITE))
      {
         return Color.BLACK;
      }
      return Color.WHITE;
   }

   /* (non-Javadoc)
    * @see java.lang.Object#hashCode()
    */
   public int hashCode()
   {
      final int prime = 31;
      int result = 1;
      result = prime * result + name.hashCode();
      return result;
   }

   /* (non-Javadoc)
    * @see java.lang.Object#equals(java.lang.Object)
    */
   public boolean equals(Object obj)
   {
      if (this == obj)
         return true;
      if (obj == null)
         return false;
      if (getClass() != obj.getClass())
         return false;
      final Color other = (Color) obj;
      return name.equals(other.name);
   }
   
   public String toString()
   {
      return this.name;
   }
}
